package com.pet.controller;

import com.pet.pojo.User;
import com.pet.service.MessageService;
import com.pet.service.UserService;
import com.pet.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/*  马小龙  和  李鹏  */
/* 两个人各写各的，完成之后可以自己尝试写其他模块 */
@RestController
@CrossOrigin
@RequestMapping("/message")
public class MessageController {
    @Autowired
    private MessageService messageService;
    @GetMapping("/getUserByName")
    public SysResult getUserByName(String userName){
        System.out.println(userName);
        User user = messageService.getUserByName(userName);
        if(user != null){
            return SysResult.success(user);
        }
        return SysResult.fail();
    }
}
